#!/usr/bin/python
# -*- coding: UTF-8 -*-

class Solution(object):
    def countStudents(self, students, sandwiches):
        """
        :type students: List[int]
        :type sandwiches: List[int]
        :rtype: int
        """
        while sandwiches:
            if students[0] != sandwiches[0]:
                students.append(students.pop(0))
            else:
                students.pop(0)
                sandwiches.pop(0)
            if len(list(set(students))) == 1 and list(set(students))[0] != sandwiches[0]:
                break
        print(len(sandwiches))
        return len(sandwiches)

Solution().countStudents([1,1,0,0],[0,1,0,1])